package com.cylise.shop.Util;

import android.app.Application;
import android.content.res.Resources;

import com.cylise.shop.R;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Cylise on 2017/7/5.
 */

public class HttpUtil  {
    public static OkHttpClient okHttpClient = new OkHttpClient();
    public static void getOKHttpRequest(String address,Callback callback){
        Request request = new Request.Builder().url(address).build();
        okHttpClient.newCall(request).enqueue(callback);
    }

    public static void postOKHttpRequest(String address, FormBody formBody, Callback callback){
        Request request = new Request.Builder().url(address).post(formBody).build();
        okHttpClient.newCall(request).enqueue(callback);
    }

    public static Response postOKHttpRequest(String address, FormBody formBody) throws IOException {
        Request request = new Request.Builder().url(address).post(formBody).build();
        return okHttpClient.newCall(request).execute();
    }
}
